package day12.homework.project3;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Optional;

import static java.util.stream.Collectors.*;

public class EmpTest {
    public static void main(String[] args) {

        List<Emp> emps = new ArrayList<>();

        emps.add(new Emp("刘备", 11600, 23, "男", "徐州"));
        emps.add(new Emp("张飞", 9700, 25, "男", "汉中"));
        emps.add(new Emp("关羽", 10300, 24, "男", "荆州"));
        emps.add(new Emp("大乔", 8600, 21, "女", "江东"));

        //统计员工人数
        int count = (int) emps.stream().count();
        //平均工资
        Double average = emps.stream().collect(averagingInt(Emp::getSalary));
        //工资总额
        int sum = emps.stream().collect(summingInt(Emp::getSalary));
        //最高工资
        Optional<Emp> max = emps.stream().collect(maxBy(Comparator.comparing(Emp::getSalary)));

        System.out.println("员工人数为: " + count);
        System.out.println("员工平均工资为: " + average);
        System.out.println("员工工资总额为: " + sum);
        System.out.println("员工最高工资为: " + max.toString());
    }
}
